package com.yunhe.servlet;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.SqlSession;

import com.yunhe.bean.UserTier;
import com.yunhe.inter.AlertuserDao;
import com.yunhe.util.SqlSessionFactoryUtil;

/**
 * Servlet implementation class AlertSerlvet
 */
@WebServlet("/AlertSerlvet")
public class AlertSerlvet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       SqlSession sqlSession;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AlertSerlvet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//查询用户下的信息
		String userName=request.getParameter("userName");
		sqlSession= SqlSessionFactoryUtil.openSqlSession();
		AlertuserDao alertdao=sqlSession.getMapper(AlertuserDao.class);
		UserTier ut=alertdao.AlertUser(userName);
		//转换日期格式为String类型
		String birthdy=new SimpleDateFormat("yyyy-MM-dd").format(ut.getBrithDate());
		request.setAttribute("birthdy", birthdy);
		request.setAttribute("UserTier", ut);
		request.getRequestDispatcher("manage/user-modify.jsp").forward(request, response);
		
		
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
